package com.logback.mvc;

import com.logback.filter.TrackIdFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenfoxin
 * @Description 自定义配置
 * @Date 2022/6/8 7:14
 **/
@Configuration
public class CustomFilterConfig  {
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new TrackIdFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        // 过滤器名称
        filterRegistrationBean.setName("logMDCFilter");
        // 过滤器顺序
        filterRegistrationBean.setOrder(0);
        return filterRegistrationBean;
    }
}
